﻿<%@ Control Language="C#"  %>
<script runat="server">
    private int item_typ=1;
    private string item_extension;
    private string folder;
    private int obj_typ = 1;
    private int Cat_width=220;
    private int Cat_height=150;
    private string Cat_mode = "Cut";
    private string file_typ = "image";
    private string ajax_url = "../ajax/UpFile.ashx";
    private string module_id;
    private int fileSizeLimit = 2048;

    public int Item_Typ
    {
        get { return item_typ; }
        set { item_typ = value; }
    }
    public string Module_Id
    {
        get { return module_id; }
        set { module_id = value; }
    }
    public int FileSizeLimit
    {
        get { return fileSizeLimit; }
        set { fileSizeLimit = value; }
    }
    public string Folder
    {
        get { return folder; }
        set { folder = value; }
    }
    public string Item_Extension
    {
        get { return item_extension; }
        set { item_extension = value; }
    }
    /// <summary>
    /// 生产2级缩略图-文件图片宽度
    /// </summary>
    public int Cat_Width
    {
        get { return Cat_width; }
        set { Cat_width = value; }
    }
    /// <summary>
    /// 生产2级缩略图-文件图片高度
    /// </summary>
    public int Cat_Height
    {
        get { return Cat_height; }
        set { Cat_height = value; }
    }
    public string Cat_Mode
    {
        get { return Cat_mode; }
        set { Cat_mode = value; }
    }
    public int Obj_Typ
    {
        get { return obj_typ; }
        set { obj_typ = value; }
    }
    public string File_Typ
    {
        get { return file_typ; }
        set { file_typ = value; }
    }
    public string Ajax_Url
    {
        get { return ajax_url; }
        set { ajax_url = value; }
    }
</script>
<link href="../pulgin/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
<script src="../pulgin/uploadify/jquery.uploadify.min.js?cache=" type="text/javascript"></script>
<script type="text/javascript">
    var returnpage="<%=Request.UrlReferrer %>";
    $(function (){
        setTimeout(function(){
            var formData={"Item_Typ": <%=Item_Typ %>,"Folder": '<%=Folder %>',"Cat_Width":<%=Cat_Width%>,"Cat_Height":<%=Cat_Height%>,"Cat_Mode":"<%=Cat_Mode %>","Item_Time":Item_Time,"Obj_Typ":<%=Obj_Typ %>,"File_Typ":'<%=File_Typ%>'}
            $('#file_upload<%=Module_Id%>').uploadify({
                'formData':formData ,
                'multi': false,
                'swf': '../pulgin/uploadify/uploadify.swf?ver=<%=DateTime.Now.ToString("yyyyMMddHHmmssfff") %>',
                'uploader': '<%=Ajax_Url%>',
                'fileTypeDesc' : '<%=Item_Extension %> ',
                'fileTypeExts': '<%=Item_Extension %>',
                'buttonText': 'ھۆججەتنى تاللاڭ ',
                'buttonImage': '../static/img/SelectMp3.png',
                'height': 39,
                'width': 49,
                'fileSizeLimit' : '<%=FileSizeLimit%>KB',
                'removeTimeout' : 0,
                'onUploadStart' : function(file) {
                    /* 存储文件扩展名 */
                    FileExt=GetFileExtName(file.name);
                    $('#file_upload<%=Module_Id%>').uploadify('settings','formData',
                        {
                            "Item_Typ": <%=Item_Typ %>,
                            "Folder": '<%=Folder %>',
                            "Cat_Width":<%=Cat_Width%>,
                            "Cat_Height":<%=Cat_Height%>,
                            "Cat_Mode":"<%=Cat_Mode %>",
                            "Item_Time":Item_Time,
                            "Obj_Typ":<%=Obj_Typ %>,
                            "File_Typ":'<%=File_Typ%>'
                        });
                },
                'onUploadSuccess': function (file, data, response) { 
                    Laoding(true);
                    var folder_times= new Date(Item_Time)
                    var img_src="../DataFile/<%=Folder %>/"+folder_times.Format("yyyyMM/ddhhmmss")+".jpg?"+(Math.random() * 1000);
                    $("#jcrop_target").attr("src",img_src);
                    $("#preview").attr("src",img_src);
                    $("#preview").load(function(){jcropLaod();})
                    $("#Image_Edit_Area").show();Laoding(false);
                },
                'onQueueComplete': function (queueData) {ShowCompleteUpImg<%=Module_Id%>() },
                'onSelectError' : function() { alert('The file asdasd ' + file.name + ' returned an error and was not added to the queue.');}
            });
        },10);
    });
</script>

<div id="queue"></div>
<input id="file_upload<%=Module_Id %>" name="file_upload" type="file"  />